'use strict'
const http = require("node:http");
const url = process.argv[2];
const url1 = process.argv[3];
const url2 = process.argv[4];

let queue = [url, url1, url2];
let result = [];
let count = 0;

// forEach 返回使用
queue.forEach((url,index) => {
  http.get(url, (res) => {

    let response = '';

    res.setEncoding("utf8");

    res.on("data", (data) => {
      response += data;
    })

    res.on('end', () => {
      result[index] = response;

      count++;

      if (count === 3) {
        result.forEach((res) => {
          console.log(res);
        })
      }
    })
  });
})
